package manage.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import manage.dao.FileTypeMapper;

import manage.model.FileType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FileTypeServiceImpl {
    @Autowired
    private FileTypeMapper FileTypeMapper;
    public PageInfo<FileType> selectAll(String page, String limit) {

        int pu = Integer.parseInt(page);
        int li = Integer.parseInt(limit);

        PageHelper.startPage(pu,li);
        List<FileType> list = FileTypeMapper.selectAll();
        PageInfo<FileType> pageInfo = new PageInfo<FileType>(list);
        return pageInfo;
    }

    public PageInfo<FileType> selectAll() {
        PageHelper.startPage(1,10000);
        List<FileType> list = FileTypeMapper.selectAll();
        PageInfo<FileType> pageInfo = new PageInfo<FileType>(list);
        return pageInfo;
    }

    public String insert(FileType record) {

        int i = FileTypeMapper.insert(record);
        if(i>0)
            return "success";
        return "fail";
    }

    public String del(Integer id) {
        int i = FileTypeMapper.deleteByPrimaryKey(id);
        if(i>0)
            return "success";
        return "fail";
    }

    public FileType select(Integer id) {
        return FileTypeMapper.selectByPrimaryKey(id);
    }
    public String update(FileType record){
        if(FileTypeMapper.updateByPrimaryKey(record)>0)
            return "success";
        return "fail";
    }
    
}
